﻿#include "FITKAbaqusHDF5AdaptorMaterial.h"
#include "FITK_Kernel/FITKCore/FITKEnumTransformer.hpp"
#include "FITK_Interface/FITKInterfaceIO/FITKAbstractHDF5Reader.h"
#include "FITK_Interface/FITKInterfaceIO/FITKAbstractHDF5Writer.h"

#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterial.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialDensity.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialElastic.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialPlastic.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialHyperElastic.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialExpansion.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialDamping.h"
#include "FITK_Interface/FITKInterfaceStructural/FITKAbaMaterialJohnsonCookDamage.h"
#include <array>

namespace IO
{
    QString FITKAbaqusHDF5AdaptorMaterial::getAdaptorClass()
    {
        return "FITKAbaqusHDF5AdaptorMaterial";
    }

    bool FITKAbaqusHDF5AdaptorMaterial::adaptR()
    {
        return FITKInterfaceHDF5AdaptorMaterial::adaptR();
    }

    bool FITKAbaqusHDF5AdaptorMaterial::adaptW()
    {
        return FITKInterfaceHDF5AdaptorMaterial::adaptW();
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readMaterial(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat || h5Group.getLocId() == -1) return false;
        bool isR = true;
        isR &= FITKInterfaceHDF5AdaptorMaterial::readMaterial(mat, h5Group);
        isR &= readJohnsonCookDamage(mat, h5Group);
        isR &= readDamping(mat, h5Group);
        isR &= readDensity(mat, h5Group);
        isR &= readElastic(mat, h5Group);
        isR &= readExpansion(mat, h5Group);
        isR &= readHyperelastic(mat, h5Group);
        isR &= readPlastic(mat, h5Group);
        return isR;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readDensity(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        if (!h5Group.nameExists("Density")) return true;
        H5::DataSet densityDataSet = h5Group.openDataSet("Density");

        //获得数据结构
        bool isDensity = mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Density);
        if (!isDensity)return false;
        auto tempDensity = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Density);
        if (!tempDensity) return false;
        auto densityData = dynamic_cast<Interface::FITKAbaMaterialDensity*>(tempDensity);
        if (!densityData) return false;

        //是否考虑温度变化
        if (!densityDataSet.attrExists("UseTemperatureDependentData")) return false;
        bool UseTemperatureDependentData = readBoolAttribute(densityDataSet, "UseTemperatureDependentData");
        densityData->setUseTemperatureDependentData(UseTemperatureDependentData);
        //设置长度
        int N = densityDataSet.getSpace().getSimpleExtentNdims();
        densityData->setNumberOfRows(N);
        // 获取数据集的维度信息
        H5::DataSpace dataspace = densityDataSet.getSpace();

        hsize_t       dimData[2]{ N ,3 };// 行数 // 列数
        H5::DataSpace elasticDataSpace(2, dimData);

        hsize_t       dim2[] = { 2 };
        H5::DataSpace mspace3(1, dim2);

        //表格
        hsize_t       coordData[2][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        for (int i = 0; i < dimData[0]; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            std::array< double, 2 > data{};
            elasticDataSpace.selectElements(H5S_SELECT_SET, 2, (const hsize_t*)coordData);
            densityDataSet.read(&data, H5::PredType::NATIVE_DOUBLE, mspace3, elasticDataSpace);

            densityData->setMassDensity(data[0], i);
            densityData->setTemperature(data[1], i);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readElastic(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;

        if (!h5Group.nameExists("Elastic")) return true;
        auto elasticGroup = h5Group.openGroup("Elastic");

        //获得数据结构
        bool isElastic = mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Elastic);
        if (!isElastic) return false;
        auto tempElastic = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Elastic);
        if (!tempElastic) return false;
        auto elasticData = dynamic_cast<Interface::FITKAbaMaterialElastic*>(tempElastic);
        if (!elasticData) return false;
        //弹性类型
        auto MaterialElasticType = readStrAttribute(elasticGroup, "MaterialElasticType");
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialElasticType> fitkWTypeTrafer;
        auto eMaterialElasticType = fitkWTypeTrafer.fromString(QString::fromStdString(MaterialElasticType), isValid);
        if (!isValid) return false;
        elasticData->setMaterialElasticType(eMaterialElasticType);

        //是否考虑温度变化
        bool UseTemperatureDependentData = readBoolAttribute(elasticGroup, "UseTemperatureDependentData");
        elasticData->setUseTemperatureDependentData(UseTemperatureDependentData);
        //不可压缩状态
        bool noCompression = readBoolAttribute(elasticGroup, "NoCompression");
        elasticData->setNoCompression(noCompression);
        //不可拉伸状态
        bool noTension = readBoolAttribute(elasticGroup, "NoTension");
        elasticData->setNoTension(noTension);
        if (!elasticGroup.nameExists("Engineering")) return false;
        H5::DataSet elasticDataSet = elasticGroup.openDataSet("Engineering");
        
        int engineeringCount = readIntAttribute(elasticGroup, "EngineeringCount");
        hsize_t       dimData[2]{ engineeringCount ,13 };// 行数 // 列数
        H5::DataSpace elasticDataSpace(2, dimData);
        //设置长度
        elasticData->setIsotropicNumberOfRows(engineeringCount);

        //写入点ID数据
        hsize_t       dim3[] = { 13 };
        H5::DataSpace mspace3(1, dim3);
        //表格
        hsize_t       coordData[13][2];
        for (int j = 0; j < dimData[1]; ++j)
        {
            coordData[j][1] = j;
        }
        for (int i = 0; i < dimData[0]; ++i)
        {
            for (int j = 0; j < dimData[1]; ++j)
            {
                coordData[j][0] = i;

            }

            std::array< double, 13 > data{ };
            elasticDataSpace.selectElements(H5S_SELECT_SET, 13, (const hsize_t*)coordData);
            elasticDataSet.read(&data, H5::PredType::NATIVE_DOUBLE, mspace3, elasticDataSpace);
            elasticData->setIsotropicYoungsModulus(data[0], i);
            elasticData->setIsotropicPoissonRatio(data[1], i);
            elasticData->setIsotropicTemperature(data[2], i);
            elasticData->setEngineeringConstantsE1(data[3], i);
            elasticData->setEngineeringConstantsE2(data[4], i);
            elasticData->setEngineeringConstantsE3(data[5], i);
            elasticData->setEngineeringConstantsNu12(data[6], i);
            elasticData->setEngineeringConstantsNu13(data[7], i);
            elasticData->setEngineeringConstantsNu23(data[8], i);
            elasticData->setEngineeringConstantsG12(data[9], i);
            elasticData->setEngineeringConstantsG13(data[10], i);
            elasticData->setEngineeringConstantsG23(data[11], i);
            elasticData->setEngineeringConstantsTemperature(data[12], i);
        }

        if (!elasticGroup.nameExists("Lamina")) return false;
        H5::DataSet laminaDataSet = elasticGroup.openDataSet("Lamina");
        int laminaCount = readIntAttribute(elasticGroup, "LaminaCount");
        hsize_t       laminaDimData[2]{ laminaCount ,7 };// 行数 // 列数
        H5::DataSpace laminaDataSpace(2, laminaDimData);
        hsize_t       laminaDim[] = { 7 };
        H5::DataSpace laminaMspace(1, laminaDim);
        for (int i = 0; i < laminaDimData[0]; ++i)
        {
            std::array< double, 7 > data{ };
            laminaDataSpace.selectElements(H5S_SELECT_SET, 7, (const hsize_t*)coordData);
            laminaDataSet.read(&data, H5::PredType::NATIVE_DOUBLE, laminaMspace, laminaDataSpace);
            elasticData->setLaminaE1(data[0], i);
            elasticData->setLaminaE2(data[1], i);
            elasticData->setLaminaNu12(data[2], i);
            elasticData->setLaminaG12(data[3], i);
            elasticData->setLaminaG13(data[4], i);
            elasticData->setLaminaG23(data[5], i);
            elasticData->setTemperature(data[6], i);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readPlastic(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        if (!h5Group.nameExists("Plastic")) return true;

        //获得数据结构
        bool isPlastic = mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Plastic);
        if (!isPlastic) return false;
        auto tempPlastic = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Plastic);
        if (!tempPlastic) return false;
        auto plasticData = dynamic_cast<Interface::FITKAbaMaterialPlastic*>(tempPlastic);
        if (!plasticData) return false;

        H5::DataSet   elasticDataSet = h5Group.openDataSet("Plastic");
        int N = elasticDataSet.getSpace().getSimpleExtentNdims();

        bool UseTemperatureDependentData = readBoolAttribute(elasticDataSet, "UseTemperatureDependentData");
        plasticData->setUseTemperatureDependentData(UseTemperatureDependentData);

        bool UseStrainRateDependentData = readBoolAttribute(elasticDataSet, "UseStrainRateDependentData");
        plasticData->setUseStrainRateDependentData(UseStrainRateDependentData);

        double JohnsonCookA = readDoubleAttribute(elasticDataSet, "JohnsonCookA");
        plasticData->setJohnsonCookA(JohnsonCookA);
        double JohnsonCookB = readDoubleAttribute(elasticDataSet, "JohnsonCookB");
        plasticData->setJohnsonCookB(JohnsonCookB);

        double JohnsonCookn = readDoubleAttribute(elasticDataSet, "JohnsonCookn");
        plasticData->setJohnsonCookn(JohnsonCookn);

        double JohnsonCookMeltingTemp = readDoubleAttribute(elasticDataSet, "JohnsonCookMeltingTemp");
        plasticData->setJohnsonCookMeltingTemp(JohnsonCookMeltingTemp);

        double JohnsonCookTransitionTemp = readDoubleAttribute(elasticDataSet, "JohnsonCookTransitionTemp");
        plasticData->setJohnsonCookTransitionTemp(JohnsonCookTransitionTemp);

        //设置长度
        plasticData->setNumberOfIsoTropicDataRows(N);
        hsize_t       dimData[2]{ N ,4 };// 行数 // 列数
        H5::DataSpace elasticDataSpace(2, dimData);

        //写入点ID数据
        hsize_t       dim3[] = { 4 };
        H5::DataSpace mspace3(1, dim3);

        //表格
        hsize_t       coordData[4][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        coordData[2][1] = 2;
        coordData[3][1] = 3;
        for (int i = 0; i < dimData[0]; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            coordData[2][0] = i;
            coordData[3][0] = i;

            std::array< double, 4 > data{};
            elasticDataSpace.selectElements(H5S_SELECT_SET, 4, (const hsize_t*)coordData);
            elasticDataSet.read(&data, H5::PredType::NATIVE_DOUBLE, mspace3, elasticDataSpace);
            plasticData->setIsotropicYieldStess(data[0], i);
            plasticData->setIsotropicPlasticStrain(data[1], i);
            plasticData->setIsotropicRate(data[2], i);
            plasticData->setIsotropicTemperature(data[3], i);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readHyperelastic(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;
        if (!h5Group.nameExists("Hyperelastic")) return true;

        //获得数据结构
        bool isHyperElastic = mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Hyperelastic);
        if (!isHyperElastic) return false;
        auto tempHyperElastic = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Hyperelastic);
        if (!tempHyperElastic) return false;
        auto hyperElasticData = dynamic_cast<Interface::FITKAbaMaterialHyperElastic*>(tempHyperElastic);
        if (!hyperElasticData) return false;

        H5::DataSet   hyperelasticDataSet = h5Group.openDataSet("Hyperelastic");
        int N = hyperelasticDataSet.getSpace().getSimpleExtentNdims();
        //温度变化
        bool UseTemperatureDependentData = readBoolAttribute(hyperelasticDataSet, "UseTemperatureDependentData");
        hyperElasticData->setUseTemperatureDependentData(UseTemperatureDependentData);

        //各向同性应变势能类型
        auto sIsoStrainEnergyPotential = readStrAttribute(hyperelasticDataSet, "IsoStrainEnergyPotential");
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticIsotropicStrainEnergyPotential> fitkHISEPypeTrafer;
        auto eIsoStrainEnergyPotential = fitkHISEPypeTrafer.fromString(QString::fromStdString(sIsoStrainEnergyPotential), isValid);
        if (!isValid) return false;
        hyperElasticData->setIsoStrainEnergyPotential(eIsoStrainEnergyPotential);

        //各向同性参数输入源
        auto sIsoInputSource = readStrAttribute(hyperelasticDataSet, "IsoInputSource");
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticIsotropicInputSource> fitkHIISPypeTrafer;
        auto eIsoInputSource = fitkHIISPypeTrafer.fromString(QString::fromStdString(sIsoInputSource), isValid);
        if (!isValid) return false;
        hyperElasticData->setIsoInputSource(eIsoInputSource);

        //各向同性Moduli Time Scale
        auto sIsoModuliTimeScale = readStrAttribute(hyperelasticDataSet, "IsoModuliTimeScale");
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticIsoModuliTimeScale> fitkHIMTSPypeTrafer;
        auto eIsoModuliTimeScale = fitkHIMTSPypeTrafer.fromString(QString::fromStdString(sIsoModuliTimeScale), isValid);
        if (!isValid) return false;
        hyperElasticData->setIsoModuliTimeScale(eIsoModuliTimeScale);

        //设置长度
        hyperElasticData->setIsoMooneyRivlinDataRows(N);
        hsize_t       dimData[2]{ N ,4 };// 行数 // 列数
        H5::DataSpace elasticDataSpace(2, dimData);

        //写入点ID数据
        hsize_t       dim3[] = { 4 };
        H5::DataSpace mspace3(1, dim3);

        //表格
        hsize_t       coordData[4][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        coordData[2][1] = 2;
        coordData[3][1] = 3;
        for (int i = 0; i < dimData[0]; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            coordData[2][0] = i;
            coordData[3][0] = i;

            std::array< double, 4 > data{};
            elasticDataSpace.selectElements(H5S_SELECT_SET, 4, (const hsize_t*)coordData);
            hyperelasticDataSet.read(&data, H5::PredType::NATIVE_DOUBLE, mspace3, elasticDataSpace);
            hyperElasticData->setIsoMooneyRivlinC10(data[0], i);
            hyperElasticData->setIsoMooneyRivlinC01(data[1], i);
            hyperElasticData->setIsoMooneyRivlinD1(data[2], i);
            hyperElasticData->setIosMooneyRivlinTemperature(data[3], i);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readExpansion(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;
        if (!h5Group.nameExists("Expansion")) return true;

        //获得数据结构
        mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Expansion);
        auto tempExpansion = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Expansion);
        auto expansionData = dynamic_cast<Interface::FITKAbaMaterialExpansion*>(tempExpansion);
        if (!expansionData) return false;

        H5::DataSet   expansionDataSet = h5Group.openDataSet("Expansion");
        int N = expansionDataSet.getSpace().getSimpleExtentNdims();

        //热膨胀属性类型。如各向同性、正交各向异性、各向异性等
        auto sExpansionType = readStrAttribute(expansionDataSet, "ExpansionType");
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialExpansionType> fitkETypeTrafer;
        auto eExpansionType = fitkETypeTrafer.fromString(QString::fromStdString(sExpansionType), isValid);
        if (!isValid) return false;
        expansionData->setExpansionType(eExpansionType);

        //参考温度
        double referenceTemperature = readDoubleAttribute(expansionDataSet, "ReferenceTemperature");
        expansionData->setReferenceTemperature(referenceTemperature);
        //属性是否随温度变化
        bool useTemperatureDependentData = readBoolAttribute(expansionDataSet, "PseTemperatureDependentData");
        expansionData->setUseTemperatureDependentData(useTemperatureDependentData);
        //参考温度
        int isotropicNumberOfRows = readIntAttribute(expansionDataSet, "IsotropicNumberOfRows");
        expansionData->setIsotropicNumberOfRows(isotropicNumberOfRows);

        hsize_t       dimData[2]{ N ,2 };// 行数 // 列数
        H5::DataSpace expansionDataSpace(2, dimData);
        hsize_t       dim3[] = { 2 };
        H5::DataSpace mspace3(1, dim3);
        //表格
        hsize_t       coordData[2][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        for (int i = 0; i < isotropicNumberOfRows; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            std::array< double, 2 > data{};
            expansionDataSpace.selectElements(H5S_SELECT_SET, 2, (const hsize_t*)coordData);
            expansionDataSet.read(&data, H5::PredType::NATIVE_DOUBLE, mspace3, expansionDataSpace);
            expansionData->setIsoTropicExpansionCoeff(data[0], i);
            expansionData->setIsotropicTemperature(data[1], i);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readJohnsonCookDamage(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        if (!h5Group.nameExists("JohnsonCookDamage")) return true;
        //获得数据结构
        mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::JohnsonCookDamage);
        Interface::FITKAbaMaterialJohnsonCookDamage* johnsonCookDamage = dynamic_cast<Interface::FITKAbaMaterialJohnsonCookDamage*>
            (mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::JohnsonCookDamage));
        if (!johnsonCookDamage) return true;

        auto  johnsonCookDamageGroup = h5Group.openGroup("JohnsonCookDamage");

        double D1 = readDoubleAttribute(johnsonCookDamageGroup, "D1");
        johnsonCookDamage->setD1(D1);
        double D2 = readDoubleAttribute(johnsonCookDamageGroup, "D2");
        johnsonCookDamage->setD2(D2);
        double D3 = readDoubleAttribute(johnsonCookDamageGroup, "D3");
        johnsonCookDamage->setD3(D3);
        double D4 = readDoubleAttribute(johnsonCookDamageGroup, "D4");
        johnsonCookDamage->setD4(D4);
        double D5 = readDoubleAttribute(johnsonCookDamageGroup, "D5");
        johnsonCookDamage->setD5(D5);

        double MeltingTemperature = readDoubleAttribute(johnsonCookDamageGroup, "MeltingTemperature");
        johnsonCookDamage->setMeltingTemperature(MeltingTemperature);
        double TransitionTemperature = readDoubleAttribute(johnsonCookDamageGroup, "TransitionTemperature");
        johnsonCookDamage->setTransitionTemperature(TransitionTemperature);
        double ReferenceStrainRate = readDoubleAttribute(johnsonCookDamageGroup, "ReferenceStrainRate");
        johnsonCookDamage->setReferenceStrainRate(ReferenceStrainRate);
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::readDamping(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        if (!h5Group.nameExists("Damping")) return true;
        auto  dampingGroup = h5Group.openGroup("Damping");

        //获取数据
        mat->addMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Damping);
        Interface::FITKAbaMaterialDamping* damping = dynamic_cast<Interface::FITKAbaMaterialDamping*>
            (mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Damping));
        if (!damping) return false;

        double alpha = readDoubleAttribute(dampingGroup, "Alpha");
        damping->setAlpha(alpha);
        double beta = readDoubleAttribute(dampingGroup, "Beta");
        damping->setBeta(beta);
        double composite = readDoubleAttribute(dampingGroup, "Composite");
        damping->setComposite(composite);
        double structural = readDoubleAttribute(dampingGroup, "Structural");
        damping->setStructural(structural);
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeMaterial(Interface::FITKAbstractMaterial * material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isW = true;
        isW &= FITKInterfaceHDF5AdaptorMaterial::writeMaterial(mat, h5Group);
        if (_h5CreateGroup.getLocId() == -1) return false;
        isW &= writeJohnsonCookDamage(mat, _h5CreateGroup);
        isW &= writeDamping(mat, _h5CreateGroup);
        isW &= writeDensity(mat, _h5CreateGroup);
        isW &= writeElastic(mat, _h5CreateGroup);
        isW &= writeExpansion(mat, _h5CreateGroup);
        isW &= writeHyperelastic(mat, _h5CreateGroup);
        isW &= writePlastic(mat, _h5CreateGroup);

        return isW;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeDensity(Interface::FITKAbstractMaterial * material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        //获得数据结构
        auto tempDensity = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Density);
        if (!tempDensity) return true;
        auto densityData = dynamic_cast<Interface::FITKAbaMaterialDensity*>(tempDensity);
        if (!densityData) return false;

        int count = densityData->getNumberOfRows();
        hsize_t       dimData[2]{ count ,2 };// 行数 // 列数
        H5::DataSpace densityDataSpace(2, dimData);
        H5::DataSet   densityDataSet = h5Group.createDataSet("Density", H5::PredType::NATIVE_DOUBLE, densityDataSpace);

        //类型
        auto MaterialBehaviorType = densityData->getMaterialBehaviorType();
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        QString TypeStr = fitkTypeTrafer.toStrting(MaterialBehaviorType, isValid);
        if (!isValid) return false;
        writeStrAttribute(densityDataSet, "MaterialBehaviorType", TypeStr.toStdString());

        //是否考虑温度变化
        bool UseTemperatureDependentData = densityData->getUseTemperatureDependentData();
        writeBoolAttribute(densityDataSet, "UseTemperatureDependentData", &UseTemperatureDependentData);

        //写入点ID数据
        hsize_t       dim2[] = { 2 };
        H5::DataSpace mspace3(1, dim2);

        //表格
        hsize_t       coordData[2][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        for (int i = 0; i < dimData[0]; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            //密度
            double massDensity = densityData->getMassDensity(i);
            //温度
            double temperature = densityData->getTemperature(i);
            const std::array< double, 2 > data{ massDensity ,temperature };
            densityDataSpace.selectElements(H5S_SELECT_SET, 2, (const hsize_t*)coordData);
            densityDataSet.write(&data, H5::PredType::NATIVE_DOUBLE, mspace3, densityDataSpace);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeElastic(Interface::FITKAbstractMaterial * material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;

        //获得数据结构
        auto tempElastic = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Elastic);
        if (!tempElastic) return true;
        auto elasticData = dynamic_cast<Interface::FITKAbaMaterialElastic*>(tempElastic);
        if (!elasticData) return false;

        auto elasticGroup = h5Group.createGroup("Elastic");

        //类型
        auto MaterialBehaviorType = elasticData->getMaterialBehaviorType();
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType> fitkTypeTrafer;
        //写出类型
        QString TypeStr = fitkTypeTrafer.toStrting(MaterialBehaviorType, isValid);
        if (!isValid) return false;
        writeStrAttribute(elasticGroup, "MaterialBehaviorType", TypeStr.toStdString());

        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialElasticType> fitkITypeTrafer;
        auto MaterialElasticType = fitkITypeTrafer.toStrting(elasticData->getMaterialElasticType(), isValid);
        if (!isValid) return false;
        //弹性类型
        writeStrAttribute(elasticGroup, "MaterialElasticType", MaterialElasticType.toStdString());

        //是否考虑温度变化
        bool UseTemperatureDependentData = elasticData->getUseTemperatureDependentData();
        writeBoolAttribute(elasticGroup, "UseTemperatureDependentData", &UseTemperatureDependentData);
        //不可压缩状态
        bool noCompression = elasticData->getNoCompression();
        writeBoolAttribute(elasticGroup, "NoCompression", &noCompression);
        //不可拉伸状态
        bool noTension = elasticData->getNoTension();
        writeBoolAttribute(elasticGroup, "NoTension", &noTension);

        int count = elasticData->getIsotropicNumberOfRows();
        writeIntAttribute(elasticGroup, "EngineeringCount", &count);

        hsize_t       dimData[2]{ count ,13 };// 行数 // 列数
        H5::DataSpace elasticDataSpace(2, dimData);
        H5::DataSet   elasticDataSet = elasticGroup.createDataSet("Engineering", H5::PredType::NATIVE_DOUBLE, elasticDataSpace);

        //写入点ID数据
        hsize_t       dim3[] = { 13 };
        H5::DataSpace mspace3(1, dim3);
        //表格
        hsize_t       coordData[13][2];
        for (int j = 0; j < dimData[1]; ++j)
        {
            coordData[j][1] = j;
        }

        for (int i = 0; i < dimData[0]; ++i)
        {
            for (int j = 0; j < dimData[1]; ++j)
            {
                coordData[j][0] = i;

            }
            double youngsModulus = elasticData->getIsotropicYoungsModulus(i);
            double poissonRatio = elasticData->getIsotropicPoisssonRatio(i);
            double temperature = elasticData->getIsotropicTemperature(i);
            double engineeringConstantsE1 = elasticData->getEngineeringConstantsE1(i);
            double engineeringConstantsE2 = elasticData->getEngineeringConstantsE2(i);
            double engineeringConstantsE3 = elasticData->getEngineeringConstantsE3(i);
            double engineeringConstantsNu12 = elasticData->getEngineeringConstantsNu12(i);
            double engineeringConstantsNu13 = elasticData->getEngineeringConstantsNu13(i);
            double engineeringConstantsNu23 = elasticData->getEngineeringConstantsNu23(i);
            double engineeringConstantsG12 = elasticData->getEngineeringConstantsG12(i);
            double engineeringConstantsG13 = elasticData->getEngineeringConstantsG13(i);
            double engineeringConstantsG23 = elasticData->getEngineeringConstantsG23(i);
            double engineeringConstantsTemperature = elasticData->getEngineeringConstantsTemperature(i);

            const std::array< double, 13 > data
            {
                youngsModulus, poissonRatio, temperature, engineeringConstantsE1,engineeringConstantsE2,engineeringConstantsE3,
                engineeringConstantsNu12,engineeringConstantsNu13,engineeringConstantsNu23,engineeringConstantsG12,engineeringConstantsG13,
                engineeringConstantsG23,engineeringConstantsTemperature
            };
            elasticDataSpace.selectElements(H5S_SELECT_SET, 13, (const hsize_t*)coordData);
            elasticDataSet.write(&data, H5::PredType::NATIVE_DOUBLE, mspace3, elasticDataSpace);
        }

        int laminaNumberOfRows = elasticData->getLaminaNumberOfRows();
        writeIntAttribute(elasticGroup, "LaminaCount", &laminaNumberOfRows);

        //写入点ID数据
        hsize_t       laminaDim[] = { 7 };
        H5::DataSpace laminamspace3(1, laminaDim);
        hsize_t       laminaDimData[2]{ laminaNumberOfRows ,7 };// 行数 // 列数
        H5::DataSpace laminaDimDataElasticDataSpace(2, laminaDimData);
        H5::DataSet   laminaElasticDataSet = elasticGroup.createDataSet("Lamina", H5::PredType::NATIVE_DOUBLE, laminaDimDataElasticDataSpace);
        for (int i = 0; i < laminaNumberOfRows; i++)
        {
            //Lamina参数
            double laminaE1 = elasticData->getLaminaE1(i);
            double laminaE2 = elasticData->getLaminaE2(i);
            double laminaNu12 = elasticData->getLaminaNu12(i);
            double laminaG12 = elasticData->getLaminaG12(i);
            double laminaG13 = elasticData->getLaminaG13(i);
            double laminaG23 = elasticData->getLaminaG23(i);
            double laminaTemperature = elasticData->getLaminaTemperature(i);

            const std::array< double, 7 > data{ laminaE1, laminaE2, laminaNu12, laminaG12,laminaG13,laminaG23,laminaTemperature };
            laminaDimDataElasticDataSpace.selectElements(H5S_SELECT_SET, 7, (const hsize_t*)coordData);
            laminaElasticDataSet.write(&data, H5::PredType::NATIVE_DOUBLE, laminamspace3, laminaDimDataElasticDataSpace);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writePlastic(Interface::FITKAbstractMaterial * material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;

        //获得数据结构
        auto tempPlastic = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Plastic);
        if (!tempPlastic) return true;
        auto plasticData = dynamic_cast<Interface::FITKAbaMaterialPlastic*>(tempPlastic);
        if (!plasticData) return false;

        int count = plasticData->getNumberOfIsotropicDataRows();
        hsize_t       dimData[2]{ count ,4 };// 行数 // 列数
        H5::DataSpace plasticDataSpace(2, dimData);
        H5::DataSet   plasticDataSet = h5Group.createDataSet("Plastic", H5::PredType::NATIVE_DOUBLE, plasticDataSpace);

        //类型
        auto MaterialBehaviorType = plasticData->getMaterialBehaviorType();
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType> fitkTypeTrafer;
        bool isValid = false;
        //写出类型
        QString TypeStr = fitkTypeTrafer.toStrting(MaterialBehaviorType, isValid);
        if (!isValid) return false;
        writeStrAttribute(plasticDataSet, "MaterialBehaviorType", TypeStr.toStdString());

        //是否考虑温度变化
        bool UseTemperatureDependentData = plasticData->getUseTemperatureDependentData();
        writeBoolAttribute(plasticDataSet, "UseTemperatureDependentData", &UseTemperatureDependentData);

        //是否使用应变率相关数据
        bool UseStrainRateDependentData = plasticData->getUseStrainRateDependentData();
        writeBoolAttribute(plasticDataSet, "UseStrainRateDependentData", &UseStrainRateDependentData);
        double JohnsonCookA = plasticData->getJohnsonCookA();
        writeDoubleAttribute(plasticDataSet, "JohnsonCookA", &JohnsonCookA);
        double JohnsonCookB = plasticData->getJohnsonCookB();
        writeDoubleAttribute(plasticDataSet, "JohnsonCookB", &JohnsonCookB);
        double JohnsonCookn = plasticData->getJohnsonCookn();
        writeDoubleAttribute(plasticDataSet, "JohnsonCookn", &JohnsonCookn);
        double JohnsonCookMeltingTemp = plasticData->getJohnsonCookMeltingTemp();
        writeDoubleAttribute(plasticDataSet, "JohnsonCookMeltingTemp", &JohnsonCookMeltingTemp);
        double JohnsonCookTransitionTemp = plasticData->getJohnsonCookTransitionTemp();
        writeDoubleAttribute(plasticDataSet, "JohnsonCookTransitionTemp", &JohnsonCookTransitionTemp);

        //写入点ID数据
        hsize_t       dim3[] = { 4 };
        H5::DataSpace mspace3(1, dim3);
        //表格
        hsize_t       coordData[4][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        coordData[2][1] = 2;
        coordData[3][1] = 3;
        for (int i = 0; i < dimData[0]; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            coordData[2][0] = i;
            coordData[3][0] = i;
            //屈服应力
            double yieldStress = plasticData->getIsotropicYieldStress(i);
            //塑性属性
            double PlasticStrai = plasticData->getIsotropicPlasticStrain(i);
            //各向同性塑性属性数据应变率
            double getIsotropicRate = plasticData->getIsotropicRate(i);
            //是否随时间变化
            double temperature = plasticData->getIsotropicTemperature(i);

            const std::array< double, 4 > data{ yieldStress, PlasticStrai, getIsotropicRate, temperature };
            plasticDataSpace.selectElements(H5S_SELECT_SET, 4, (const hsize_t*)coordData);
            plasticDataSet.write(&data, H5::PredType::NATIVE_DOUBLE, mspace3, plasticDataSpace);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeHyperelastic(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;

        //获得数据结构
        auto tempHyperElastic = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Hyperelastic);
        if (!tempHyperElastic) return true;
        auto hyperElasticData = dynamic_cast<Interface::FITKAbaMaterialHyperElastic*>(tempHyperElastic);
        if (!hyperElasticData) return false;

        int count = hyperElasticData->getIsoMooneyRivlinDataRows();
        hsize_t       dimData[2]{ count ,4 };// 行数 // 列数
        H5::DataSpace plasticDataSpace(2, dimData);
        H5::DataSet   hyperelasticDataSet = h5Group.createDataSet("Hyperelastic", H5::PredType::NATIVE_DOUBLE, plasticDataSpace);

        //材料类型
        auto eMaterialType = hyperElasticData->getMaterialType();
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticMaterialType> fitkTypeTrafer;
        //写出类型
        QString TypeStr = fitkTypeTrafer.toStrting(eMaterialType, isValid);
        if (!isValid) return false;
        writeStrAttribute(hyperelasticDataSet, "MaterialType", TypeStr.toStdString());

        //是否考虑温度变化
        bool UseTemperatureDependentData = hyperElasticData->getUseTemperatureDependentData();
        writeBoolAttribute(hyperelasticDataSet, "UseTemperatureDependentData", &UseTemperatureDependentData);

        //各向同性应变势能类型
        auto eIsoStrainEnergyPotential = hyperElasticData->getIsoStrainEnergyPotential();
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticIsotropicStrainEnergyPotential> fitkHISEPypeTrafer;
        QString sIsoStrainEnergyPotential = fitkHISEPypeTrafer.toStrting(eIsoStrainEnergyPotential, isValid);
        if (!isValid) return false;
        writeStrAttribute(hyperelasticDataSet, "IsoStrainEnergyPotential", sIsoStrainEnergyPotential.toStdString());

        //各向同性参数输入源
        auto eIsoInputSource = hyperElasticData->getIsoInputSource();
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticIsotropicInputSource> fitkHIISPypeTrafer;
        QString sIsoInputSource = fitkHIISPypeTrafer.toStrting(eIsoInputSource, isValid);
        if (!isValid) return false;
        writeStrAttribute(hyperelasticDataSet, "IsoInputSource", sIsoInputSource.toStdString());

        //各向同性Moduli Time Scale
        auto eIsoModuliTimeScale = hyperElasticData->getIsoModuliTimeScale();
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::HyperelasticIsoModuliTimeScale> fitkHIMTSPypeTrafer;
        QString sIsoModuliTimeScale = fitkHIMTSPypeTrafer.toStrting(eIsoModuliTimeScale, isValid);
        if (!isValid) return false;
        writeStrAttribute(hyperelasticDataSet, "IsoModuliTimeScale", sIsoModuliTimeScale.toStdString());

        //写出长度
        writeIntAttribute(hyperelasticDataSet, "IsoMooneyRivlinDataRows", &count);
        //写入点ID数据
        hsize_t       dim3[] = { 4 };
        H5::DataSpace mspace3(1, dim3);

        //表格
        hsize_t       coordData[4][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        coordData[2][1] = 2;
        coordData[3][1] = 3;
        for (int i = 0; i < dimData[0]; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;
            coordData[2][0] = i;
            coordData[3][0] = i;
            //各向同性MooneyRivlin参数C10
            double IsoMooneyRivlinC10 = hyperElasticData->getIsoMooneyRivlinC10(i);
            //各向同性MooneyRivlin参数C01
            double IsoMooneyRivlinC01 = hyperElasticData->getIsoMooneyRivlinC01(i);
            //各向同性MoonneyRivlin参数D1
            double IsoMooneyRivlinD1 = hyperElasticData->getIsoMooneyRivlinD1(i);
            //各向同性MoonneyRivlin参数温度
            double IsoMooneyRivlinTemperature = hyperElasticData->getIsoMooneyRivlinTemperature(i);

            const std::array< double, 4 > data{ IsoMooneyRivlinC10, IsoMooneyRivlinC01, IsoMooneyRivlinD1, IsoMooneyRivlinTemperature };
            plasticDataSpace.selectElements(H5S_SELECT_SET, 4, (const hsize_t*)coordData);
            hyperelasticDataSet.write(&data, H5::PredType::NATIVE_DOUBLE, mspace3, plasticDataSpace);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeExpansion(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;

        //获得数据结构
        auto tempExpansion = mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Expansion);
        if (!tempExpansion) return true;
        auto expansionData = dynamic_cast<Interface::FITKAbaMaterialExpansion*>(tempExpansion);
        if (!expansionData) return false;

        int count = expansionData->getIsotropicNumberOfRows();
        hsize_t       dimData[2]{ count ,2 };// 行数 // 列数
        H5::DataSpace plasticDataSpace(2, dimData);
        H5::DataSet   expansionDataSet = h5Group.createDataSet("Expansion", H5::PredType::NATIVE_DOUBLE, plasticDataSpace);

        //材料属性行为类型
        auto MaterialBehaviorType = expansionData->getMaterialBehaviorType();
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType> fitkTypeTrafer;
        QString TypeStr = fitkTypeTrafer.toStrting(MaterialBehaviorType, isValid);
        if (!isValid) return false;
        writeStrAttribute(expansionDataSet, "MaterialBehaviorType", TypeStr.toStdString());

        //热膨胀属性类型。如各向同性、正交各向异性、各向异性等
        auto eExpansionType = expansionData->getExpansionType();
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialExpansionType> fitkETypeTrafer;
        QString sExpansionType = fitkETypeTrafer.toStrting(eExpansionType, isValid);
        if (!isValid) return false;
        writeStrAttribute(expansionDataSet, "ExpansionType", sExpansionType.toStdString());
        //参考温度
        double referenceTemperature = expansionData->getReferenceTemperature();
        writeDoubleAttribute(expansionDataSet, "ReferenceTemperature", &referenceTemperature);
        //属性是否随温度变化
        bool useTemperatureDependentData = expansionData->getUseTemperatureDependentData();
        writeBoolAttribute(expansionDataSet, "PseTemperatureDependentData", &useTemperatureDependentData);
        //参考温度
        int isotropicNumberOfRows = expansionData->getIsotropicNumberOfRows();
        writeIntAttribute(expansionDataSet, "IsotropicNumberOfRows", &isotropicNumberOfRows);
        //写入点ID数据
        hsize_t       dim3[] = { 2 };
        H5::DataSpace mspace3(1, dim3);
        //表格
        hsize_t       coordData[2][2];
        coordData[0][1] = 0;
        coordData[1][1] = 1;
        for (int i = 0; i < isotropicNumberOfRows; ++i)
        {
            coordData[0][0] = i;
            coordData[1][0] = i;

            //各向同性膨胀系数
            double IsotropicExpansionCoeff = expansionData->getIsotropicExpansionCoeff(i);
            //各向同性温度值
            double IsotropicTemperature = expansionData->getIsotropicTemperature(i);
            const std::array< double, 2 > data{ IsotropicExpansionCoeff, IsotropicTemperature };
            plasticDataSpace.selectElements(H5S_SELECT_SET, 2, (const hsize_t*)coordData);
            expansionDataSet.write(&data, H5::PredType::NATIVE_DOUBLE, mspace3, plasticDataSpace);
        }
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeJohnsonCookDamage(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;

        //获取数据
        Interface::FITKAbaMaterialJohnsonCookDamage* johnsonCookDamage = dynamic_cast<Interface::FITKAbaMaterialJohnsonCookDamage*>
            (mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::JohnsonCookDamage));
        if (!johnsonCookDamage) return true;

        auto  DamageInitiationGroup = h5Group.createGroup("JohnsonCookDamage");

        //类型
        auto MaterialBehaviorType = johnsonCookDamage->getMaterialBehaviorType();
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType> fitkTypeTrafer;
        //写出类型
        QString sMaterialBehaviorType = fitkTypeTrafer.toStrting(MaterialBehaviorType, isValid);
        if (!isValid) return false;
        writeStrAttribute(DamageInitiationGroup, "MaterialBehaviorType", sMaterialBehaviorType.toStdString());

        double D1 = johnsonCookDamage->getD1();
        writeDoubleAttribute(DamageInitiationGroup, "D1", &D1);
        double D2 = johnsonCookDamage->getD2();
        writeDoubleAttribute(DamageInitiationGroup, "D2", &D2);
        double D3 = johnsonCookDamage->getD3();
        writeDoubleAttribute(DamageInitiationGroup, "D3", &D3);
        double D4 = johnsonCookDamage->getD4();
        writeDoubleAttribute(DamageInitiationGroup, "D4", &D4);
        double D5 = johnsonCookDamage->getD5();
        writeDoubleAttribute(DamageInitiationGroup, "D5", &D5);
        double MeltingTemperature = johnsonCookDamage->getMeltingTemperature();
        writeDoubleAttribute(DamageInitiationGroup, "MeltingTemperature", &MeltingTemperature);
        double TransitionTemperature = johnsonCookDamage->getTransitionTemperature();
        writeDoubleAttribute(DamageInitiationGroup, "TransitionTemperature", &TransitionTemperature);
        double ReferenceStrainRate = johnsonCookDamage->getReferenceStrainRate();
        writeDoubleAttribute(DamageInitiationGroup, "ReferenceStrainRate", &ReferenceStrainRate);
        return true;
    }

    bool FITKAbaqusHDF5AdaptorMaterial::writeDamping(Interface::FITKAbstractMaterial* material, H5::Group & h5Group)
    {
        auto mat = dynamic_cast<Interface::FITKAbaMaterial*>(material);
        if (!mat) return false;
        bool isValid = false;

        //获取数据
        Interface::FITKAbaMaterialDamping* damping = dynamic_cast<Interface::FITKAbaMaterialDamping*>
            (mat->getMaterialBehavior(Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType::Damping));
        if (!damping) return true;
        auto  DampingGroup = h5Group.createGroup("Damping");
        //类型
        auto MaterialBehaviorType = damping->getMaterialBehaviorType();
        //枚举转换字符
        Core::FITKEnumTransfer<Interface::FITKAbaMaterialBehaviorEnum::FITKAbaMaterialBehaviorType> fitkTypeTrafer;
        //写出类型
        QString sMaterialBehaviorType = fitkTypeTrafer.toStrting(MaterialBehaviorType, isValid);
        if (!isValid) return false;
        writeStrAttribute(DampingGroup, "MaterialBehaviorType", sMaterialBehaviorType.toStdString());

        double alpha = damping->getAlpha();
        writeDoubleAttribute(DampingGroup, "Alpha", &alpha);

        double beta = damping->getBeta();
        writeDoubleAttribute(DampingGroup, "Beta", &beta);

        double composite = damping->getComposite();
        writeDoubleAttribute(DampingGroup, "Composite", &composite);

        double structural = damping->getStructural();
        writeDoubleAttribute(DampingGroup, "Structural", &structural);
        return true;
    }

}
